<div ng-controller="GetUnitCtrl">
<div class="panel panel-default">

 	<div class="panel-body" style="padding-top: 0;padding-bottom: 0;">
  		<div class="nav navbar-nav m-t">
 			            
            <span><b>系统设置</b></span>
            <i class="fa fa-angle-right" style="font-size:20px"></i>
            <span><b>单元管理</b> </span>
            <i class="fa fa-angle-right" style="font-size:20px"></i>
            <span><b>单元列表</b></span> 
         </div>
        <!-- nabar right -->
        <ul class="nav navbar-nav navbar-right" ng-controller="SigninFormController">          
          <li class="dropdown" dropdown>
            <a href class="dropdown-toggle clear" dropdown-toggle>
              <span class="thumb-sm avatar pull-right m-t-n-sm m-b-n-sm m-l-sm">
                <img src="img/a0.jpg" alt="...">
                <i class="on md b-white bottom"></i>
              </span>
              <span class="hidden-sm hidden-md"><b>{{namedata}}</b></span> <b class="caret"></b>
            </a>
            <!-- dropdown -->
            <ul class="dropdown-menu animated fadeInRight w">  
              <li>
                <a ui-sref="app.user.info">用户信息</a>
              </li>       
              <li class="divider"></li>
              <li>
                <a ui-sref="access.signin" ng-click="logout()">登出</a>
              </li>
            </ul>
            <!-- / dropdown -->
          </li>
        </ul>
 	</div>
</div>
<div class="panel m-t-n-md">
	<div class="panel-body" style="padding-top: 5px;padding-bottom:5px">
		<div class="row">			
		
			<div class="col-md-2">				
				<select class="form-control btn-rounded" style="padding: 5px 10px;font-weight: bold;background: rgb(245,245,245)" ng-model="b.school_name" ng-options="key as key for (key,value) in mmData" ng-change="b.buildingtype='';b.building_name='';b.layer_name='';">
	                 <!--  <option value="">所有学校</option>   -->              
	            </select>
			</div>
			<div class="col-md-2">
				
				<select class="form-control btn-rounded" ng-model="b.buildingtype" style="padding: 5px 10px;font-weight: bold;background: rgb(245,245,245)"  ng-change="b.building_name='';b.layer_name='';">
		                <option value="">所有类型</option>
		                <option ng-if="key!='school_id'&&key!='school_name'&&key!='所有类型'" ng-repeat="(key,value) in mmData[b.school_name]" value="{{key}}+{{mmData[b.school_name].school_id}}">{{key}}</option >
		        </select>
			</div>
				<div class="col-md-2 " >						
				<select class="form-control btn-rounded" ng-model="b.building_name" style="padding: 5px 10px;font-weight: bold;background: rgb(245,245,245)" ng-options="key as key for (key,value) in mmData[b.school_name][b.buildingtype.split('+')[0]]" ng-change="b.layer_name='';">
                 	<option value="">所有楼</option>                  
                </select>
	          
			</div>
			<div class="col-md-2">
				
				<select class="form-control btn-rounded" ng-model="b.layer_name" style="padding: 5px 10px;font-weight: bold;background: rgb(245,245,245)">
                  <option value="">所有层</option>
                <!--   <option value="{{mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].campus_id}}+所有层" ng-if="value!=''">所有层</option> -->
                  <option ng-if="value!='所有层'"  ng-repeat="(key,value) in mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].layers" value="{{value.layer_name}}+{{mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].campus_id}}+{{value.layer_id}}">                
                    {{value.layer_name}}
                  </option>
                  
                </select>                       
			</div>
			<div class="col-md-1">
				<button class="btn btn-sm btn-default btn-rounded m-t-xs" style="border-color:rgb(107,166,226);background: 0 0; font-weight: bold;color: rgb(107,166,226) !important;width: 100%" ng-click="search()">确定</button>
			</div>
			<div class="col-md-1 pull-right">
				<!-- <div class=""> -->
					<button class="btn btn-sm btn-rounded btn-info" ng-controller="NewUnitModalCtrl"  ng-click="open()">
					    <script type="text/ng-template" id="newunitModalContent.html">
			                 <div ng-include="'tpl/sys/unit/newmodal.html'"></div>
			            </script> 
			            <span>新增单元</span> 
			        </button>
				<!-- </div> -->
			</div>
		</div>
	</div>
</div>
<div class="panel panel-default m-t-n-md">
	<div class="panel-body">
		
		<table class="table" style="border: none;">
			<thead>
				<tr>
					<th>单元名称</th>
					<th>学校</th>
					<th>类型</th>
					<th>楼名称</th>	
					<th>寝室长</th>	
					<th>管理员</th>		
					<th>维保人员</th>	
					<th>操作</th>				
				</tr>
			</thead>
			<tbody>
				<tr ng-repeat="aaData in aaData">
					<td>
						<a ui-sref="app.sys.unitinfo({unitid:aaData.room_id,page:$scope.currentPage})" style="color: rgb(28,99,161)">{{aaData.room_name}}</a>
					</td>
					<td>
						{{aaData.school_name}}
					</td>
					<td>
						{{aaData.building_type}}
					</td>
					<td>{{aaData.building_name}}</td>
					<td>{{aaData.room_leader}}</td>
					<td>{{aaData.admin_name}}</td>
					<td>{{aaData.maintenance_personnel}}</td>
					<td>
						<a class="btn btn-xs btn-info" ng-controller="AddManagerModalCtrl" ng-click="addmanager(aaData.room_id,aaData.school_id)">
							<script type="text/ng-template" id="addmanagerModalContent.html">
				                 <div ng-include="'tpl/sys/unit/addmanagermodal.html'"></div>
				            </script> 
				            <span>添加管理员</span> 						
						</a>
						<a class="btn btn-xs btn-success" ng-controller="AddStudentModalCtrl" ng-click="addstudent(aaData.room_id,aaData.school_id)">
							<script type="text/ng-template" id="addstudentModalContent.html">
				                 <div ng-include="'tpl/sys/unit/addstudentmodal.html'"></div>
				            </script> 
				            <span>添加学生</span> 
						</a>

						<a class="btn btn-xs btn-danger" ng-controller="DelUnitModalCtrl"  ng-click="delunit(aaData.room_id,aaData.school_id)">
							<script type="text/ng-template" id="delunitModalContent.html">
				                <div ng-include="'tpl/sys/unit/delmodal.html'"></div>
				            </script> 
				            <span>删除</span> 
						</a>
					</td>
					
				</tr>				
			</tbody>
		</table>

		<div class="text-center">
          <pagination boundary-links="true" total-items="totalItems"
          ng-model="currentPage" class="pagination-sm embed-responsive-item"
          previous-text="上一页"
          next-text="下一页"
          first-text="首页"
          last-text="尾页"
          max-size="maxSize"
          rotate="false" num-pages="numPages" ng-change="pageChanged()">
         </pagination>
      </div>  



    </div>
</div>

</div>
